{% extends "StartGroup/groupHome.html" %}
{% block portraitUpload %}{% endblock %}
{% block announcements %}{% endblock %}
{% block content %}

    <div class="announcement">
        {% if permission == "Owner" or permission == "Board Member" or permission == "Assistant Board Member" %}
            <a href="/connectpeople/{{ group.group_web_address }}/docs/postDoc">Post New Document</a>
        {% endif%}
        {% for each in docs %}
        <div  id="{{ each.id }}">
            <div class="clearbreak nobreak announcementTitle">
                    {{forloop.counter }}. <strong><a href="{{each.file}}">{{each.title}}</a>  </strong>
                    {% if permission == "Owner" or permission == "Board Member" or each.post_by == userid %}
                        <a href="#" docid="{{ each.id }}" class="delEvent"><img class="eventTrashImg" title="delete" src="/{{ media_url }}/StartGroup/images/trash_icon.png"/></a>
                    {% endif %}
            </div>
            <div class="nobreak clearbreak announcementDesc">
                    {{each.description}}
            </div>
        </div>
        {% endfor %}
    </div>
{% endblock %}
{% block extra_js %}
    <script src="/static_media/contifyuser/js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
	$(document).ready(function(){$("a.delEvent").click(function(){
	    var docid = $(this).attr('docid');
	    jQuery.ajax({
	      url: '/connectpeople/{{ group.group_web_address }}/docs/view',
	      type: 'POST',
	      data: {'docid':docid, 'action':'deleteDoc'},
	      dataType: 'json',
	      success: function(json){
                document.getElementById(docid).style.display="none";
	    },
	      error: function(xhr, ajaxOptions, thrownError){
		alert("An Error Has Occurred. Please try again.");
	      }
	    });
	});
	});
    </script>
{% endblock %}